home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / passwd+ / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  19.8 KB  |  828 lines

  1.  
  2. # line 2 "test.y"
  3. /*
  4.  * this file implements the grammar for the password tests
  5.  * the escapes are handled in the caller
  6.  */
  7.  
  8. #include "passwd.h"
  9.  
  10.  
  11. # line 14 "test.y"
  12. typedef union  {
  13.     char *cval;        /* something parsed as a string */
  14.     int ival;        /* something parsed as a number */
  15. } YYSTYPE;
  16. # define AND 257
  17. # define DIV 258
  18. # define EOL 259
  19. # define EQ 260
  20. # define FILENAME 261
  21. # define GE 262
  22. # define GT 263
  23. # define LE 264
  24. # define LPAR 265
  25. # define LT 266
  26. # define MINUS 267
  27. # define MOD 268
  28. # define NE 269
  29. # define NOT 270
  30. # define NUMBER 271
  31. # define OR 272
  32. # define PATEQ 273
  33. # define PATNE 274
  34. # define STRING 275
  35. # define PLUS 276
  36. # define PROGRAM 277
  37. # define RPAR 278
  38. # define TIMES 279
  39. # define UNK 280
  40.  
  41. # line 67 "test.y"
  42.  
  43. /*
  44.  * variables
  45.  */
  46. static int retval;        /* 1 if test passed, 0 if not */
  47. static char *lptr;        /* used to walk input string */
  48. static int ateol;        /* 1 when you hit end of string */
  49.  
  50. #define yyclearin yychar = -1
  51. #define yyerrok yyerrflag = 0
  52. extern int yychar;
  53. extern short yyerrflag;
  54. #ifndef YYMAXDEPTH
  55. #define YYMAXDEPTH 150
  56. #endif
  57. YYSTYPE yylval, yyval;
  58. # define YYERRCODE 256
  59.  
  60. # line 221 "test.y"
  61.  
  62.  
  63. /*
  64.  * this is the lexer -- it's pretty dumb
  65.  */
  66. yylex()
  67. {
  68.     static char parbuf[BUFSIZ];    /* used to save strings */
  69.     register int rval;        /* used for return values */
  70.     register char quo;        /* used to hold terminal quote mark */
  71.  
  72.     /*
  73.      * this is hit at the end of string
  74.      * we need to do it this way because the '\0' (EOL)
  75.      * token must be returned, so we have toi return
  76.      * another "end of input" token -- in other words,
  77.      * the end of input character is NOT the same as 
  78.      * the end of string (EOL) character
  79.  
  80.      */
  81.     if (ateol){
  82.         ateol = 0;
  83.         return(-1);    /* YACC's end of file character */
  84.     }
  85.  
  86.     /*
  87.      * eat leading white spaces; may have a backslash in front
  88.      * (since a tab separates the test field and the message
  89.      * field, if there is a tab in the test field it must be
  90.      * escaped)
  91.      */
  92.     while(*lptr)
  93.         if (isspace(*lptr))
  94.             lptr++;
  95.         else if (*lptr == '\\'){
  96.             if (isspace(lptr[1]))
  97.                 lptr += 2;
  98.             else
  99.                 break;
  100.         }
  101.         else
  102.             break;
  103.  
  104.     /*
  105.      * hit end of string character
  106.      * indicate there's nothing more with ateol
  107.      * (so next tile we return YACC's end of file)
  108.      * and return the EOL token
  109.      */
  110.     if (*lptr == '\0'){
  111.         ateol = 1;
  112.         return(EOL);
  113.     }
  114.  
  115.     /*
  116.      * number -- just return it
  117.      */
  118.     if (isdigit(*lptr)){
  119.         for(rval = 0; isdigit(*lptr); lptr++)
  120.             rval = rval * 10 + *lptr - '0';
  121.         yylval.ival = rval;
  122.         return(NUMBER);
  123.     }
  124.  
  125.     /*
  126.      * something else -- analyze it
  127.      */
  128.     switch(*lptr++){
  129.     case '@':        /* rest of line is comment */
  130.     case '\t':        /* rest of line is error message */
  131.     case '\n':        /* end of line */
  132.     case '\0':        /* end of line */
  133.         ateol = 1;
  134.         return(EOL);
  135.     case '(':        /* begin grouping */
  136.         return(LPAR);
  137.     case ')':        /* end grouping */
  138.         return(RPAR);
  139.     case '~':        /* negation */
  140.         return(NOT);
  141.     case '+':        /* add */
  142.         return(PLUS);
  143.     case '-':        /* subtract */
  144.         return(MINUS);
  145.     case '*':        /* multiply */
  146.         return(TIMES);
  147.     case '/':        /* divide */
  148.         return(DIV);
  149.     case '%':        /* remainder */
  150.         return(MOD);
  151.     case '&':        /* disjunction */
  152.         if (*lptr++ == '&')    /* && */
  153.             return(AND);
  154.         --lptr;            /* & */
  155.         return(AND);
  156.     case '|':        /* conjunction */
  157.         if (*lptr++ == '|')    /* || */
  158.             return(OR);
  159.         --lptr;            /* | */
  160.         return(OR);
  161.     case '>':        /* relation */
  162.         if (*lptr++ == '=')    /* >= */
  163.             return(GE);
  164.         --lptr;            /* > */
  165.         return(GT);
  166.     case '<':        /* relation */
  167.         if (*lptr++ == '=')    /* <= */
  168.             return(LE);
  169.         --lptr;            /* < */
  170.         return(LT);
  171.     case '!':        /* relation, logical negation */
  172.         if (*lptr++ == '=')    /* != */
  173.             return(NE);
  174.         --lptr;    
  175.         if (*lptr++ == '~')    /* !~ */
  176.             return(PATNE);
  177.         --lptr;            /* logical negation */
  178.         return(NOT);
  179.     case '=':
  180.         if (*lptr++ == '=')    /* == */
  181.             return(EQ);
  182.         --lptr;    
  183.         if (*lptr++ == '~')    /* =~ */
  184.             return(PATEQ);
  185.         --lptr;            /* = */
  186.         return(EQ);
  187.     case '\'':            /* pattern */
  188.     case '"':            /* pattern */
  189.     case '{':            /* program */
  190.     case '[':            /* file */
  191.         /*
  192.          * figure out what you're dealing with
  193.          */
  194.         if (lptr[-1] == '\'' || lptr[-1] == '"'){    /* pattern */
  195.             quo = lptr[-1];
  196.             rval = STRING;
  197.         }
  198.         else if (lptr[-1] == '{'){    /* program */
  199.             quo = '}';
  200.             rval = PROGRAM;
  201.         }
  202.         else{                /* file */
  203.             quo = ']';
  204.             rval = FILENAME;
  205.         }
  206.         /*
  207.          * collect the file or program or pattern
  208.          */
  209.         lptr = getcstring(lptr, parbuf, quo);
  210.         /*
  211.          * if no closing quote, warn but accept;
  212.          * if a closing quote, skip it
  213.          */
  214.         if (!*lptr)
  215.             yyerror("missing quote -- supplying it");
  216.         else
  217.             lptr++;
  218.         /*
  219.          * return the file or program as the value
  220.          */
  221.         yylval.cval = strsave(parbuf);
  222.         return(rval);
  223.     }
  224.  
  225.     /*
  226.      * unknown
  227.      */
  228.     return(UNK);
  229. }
  230.  
  231. /*
  232.  * report error on a pattern (malformed ...)
  233.  */
  234. paterr(msg)
  235. char *msg;        /* error message from pattern compiler/matcher */
  236. {
  237.     /*
  238.      * print the error message
  239.      */
  240.     LOG3(LG_SYNTAX, "%s at line %d (at \"%s\")", msg, linect, lptr-1);
  241. }
  242.  
  243. /*
  244.  * report system errors
  245.  */
  246. sysyyerror(s)
  247. char *s;        /* what screwed up */
  248. {
  249.     char buf[BUFSIZ];    /* buffer for error message */
  250.  
  251.     /*
  252.      * print the system error message if available,
  253.      * or the error number if not
  254.      */
  255.     if (errno < sys_nerr)
  256.         SPRINTF(buf, "line %d: %s: %s at \"%s\"",
  257.                     linect, s, sys_errlist[errno], lptr-1);
  258.     else
  259.         SPRINTF(buf, "line %d: %s: unknown error #%d at \"%s\"",
  260.                         linect, s, errno, lptr-1);
  261.     LOG0(LG_SYSTEM, buf);
  262. }
  263.  
  264. /*
  265.  * report grammar errors (yacc)
  266.  */
  267. yyerror(s)
  268. char *s;        /* how the parse screwed up */
  269. {
  270.     /*
  271.      * print the error message
  272.      */
  273.     LOG3(LG_SYNTAX, "%s at line %d (at \"%s\")", s, linect, lptr-1);
  274.  
  275.     /*
  276.      * signal end of test
  277.      */
  278.     ateol = 1;
  279. }
  280.  
  281. /*==================== DRIVER ====================*/
  282. /*
  283.  * this runs the test in "buf" on the password
  284.  * and returns 1 if it passes, 0 of not
  285.  */
  286. passtest(buf)
  287. char *buf;            /* the test */
  288. {
  289.     /*
  290.      * clear the end of line flag
  291.      */
  292.     ateol = 0;
  293.  
  294.     /*
  295.      * clobber any trailing newline
  296.      */
  297.     lptr = &buf[strlen(buf)-1];
  298.     if (*lptr == '\n')
  299.         *lptr = '\0';
  300.     else
  301.         lptr[2] = '\0';
  302.  
  303. printf("TEST :%s:\n", buf);
  304.     /*
  305.      * set up the pointer to the input
  306.      * for yylex, the lexical analyzer
  307.      */
  308.     lptr = buf;
  309.  
  310.     /*
  311.      * parse the date and process the result
  312.      */
  313.     if (yyparse()){
  314. #ifdef DEBUG
  315.         PRINTF("illegal test for password\n");
  316. #endif
  317.         return(0);
  318.     }
  319.  
  320.     /*
  321.      * test is syntactically and semantically correct
  322.      * and return the result
  323.      */
  324. #ifdef DEBUG
  325.     PRINTF("password \"%s\" %s this test\n",
  326.             password, retval ? "passes" : "does not pass");
  327. #endif
  328.     return(retval);
  329. }
  330.     
  331.  
  332.  
  333.  
  334. /*===================== M A I N  C A L L I N G  R O U T I N E S ==============*/
  335. /*
  336.  * two sets of main routines
  337.  * if "DEBUG" is defined, you get a main routine that reads in one date,
  338.  * parses it, and prints the result
  339.  * if "DEBUG" is not defined, you get a routine that returns 1 if the current
  340.  * time is within the time range of the argument string, 0 if not
  341.  *
  342.  * "DEBUG" san be set to two levels; "1" gives you just the result (1 or 0),
  343.  * but you can use the print function "prtime()" to print out key times in
  344.  * the parse.  "2" gives you complete debugging info from YACC as well
  345.  */
  346.  
  347. #ifdef DEBUG
  348.  
  349. /*
  350.  * set the flag YYDEBUG
  351.  */
  352. #if DEBUG > 1
  353. #define YYDEBUG        /* flag so YACC will generate debugging info */
  354. extern int yydebug;    /* constant to tell YACC to generate debugging info */
  355. #endif
  356.  
  357. int linect = 0;        /* number of expression being tested */
  358. char *password;        /* password being tested */
  359.  
  360. /*
  361.  * main routine -- execute the given test and print the result
  362.  */
  363. main()
  364. {
  365.     char buf[BUFSIZ];        /* input buffer */
  366.     char pbuf[BUFSIZ];        /* buffer for password */
  367.     register char *p, *b;        /* used to load password */
  368.  
  369. #if DEBUG > 1
  370.     yydebug = 1;        /* YACC is to give full debugging output */
  371. #endif
  372.  
  373.     /*
  374.      * initialize the password to nothing
  375.      */
  376.     pbuf[0] = '\0';
  377.  
  378.     /*
  379.      * get the input; if EOF, quit
  380.      */
  381.     while(fgets(buf, BUFSIZ, stdin) != CH_NULL){
  382.         /*
  383.          * if it is a new password change the old one
  384.          */
  385.         if (buf[0] == 'p'){
  386.             for(b = &buf[1]; isspace(*b); b++)
  387.             p = pbuf;
  388.             while(*b && *b != '\n')
  389.                 *p++ = *b++;
  390.             *p = '\0';
  391.             PRINTF("new password is \"%s\"\n", pbuf);
  392.             password = pbuf;
  393.             initpw();
  394.             continue;
  395.         }
  396.  
  397.         /*
  398.          * if there is no password, warn
  399.          */
  400.         if (pbuf[0] == '\0'){
  401.             PRINTF("no password; say 'p <password>' to set one\n");
  402.             continue;
  403.         }
  404.  
  405.         /*
  406.          * new expression
  407.          */
  408.         linect++;
  409.  
  410.         /*
  411.          * print the buffer
  412.          */
  413.         PRINTF("buf is <%s>\n", buf);
  414.  
  415.         /*
  416.          * parse the date and process the result
  417.          */
  418.         (void) passtest(buf);
  419.     }
  420.  
  421.     /*
  422.      * no problem
  423.      */
  424.     exit(0);
  425. }
  426.  
  427. #endif
  428. short yyexca[] ={
  429. -1, 1,
  430.     0, -1,
  431.     -2, 0,
  432.     };
  433. # define YYNPROD 45
  434. # define YYLAST 156
  435. short yyact[]={
  436.  
  437.   44,  47,  38,  14,  39,  36,  40,  15,  35,  42,
  438.   45,  37,  13,  72,  17,  71,  42,  19,  41,  70,
  439.   52,  43,  44,  69,  38,  41,  39,  36,  40,  18,
  440.   35,  42,  45,  37,  68,  51,   3,  67,  66,   4,
  441.   41,  10,  65,  43,  44,   5,  17,  14,  16,   7,
  442.    6,  15,   2,  42,  45,   9,  13,  11,  20,  22,
  443.    1,  18,  41,  10,  52,  43,  44,   5,  17,  14,
  444.   49,  50,   6,  15,  63,  42,  45,   9,  13,  11,
  445.   60,  57,   8,  18,  41,  54,   0,  43,  62,  31,
  446.   64,  27,   0,   0,  59,  56,  61,  58,  32,  53,
  447.   28,  55,  33,  34,  29,  30,  23,  12,   0,   0,
  448.    0,   0,   0,  21,   0,  24,   0,   0,   0,  25,
  449.   26,  46,  48,   0,   0,   0,   0,   0,   0,   0,
  450.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  451.    0,   0,   0,  73,  74,  75,  76,  77,  78,  79,
  452.   80,  81,  82,  83,   0,  84 };
  453. short yypact[]={
  454.  
  455. -220,-1000,-211,-242,-1000,-198,-198,-1000,-1000,-154,
  456. -169,-171,-236,-264,-264,-1000,-1000,-198,-198,-1000,
  457. -243,-258,-189,-176,-180,-181,-187,-233,-237,-238,
  458. -241,-252,-256,-260,-262,-264,-264,-264,-264,-264,
  459. -264,-264,-264,-264,-264,-264,-251,-264,-251,-1000,
  460. -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  461. -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  462. -1000,-1000,-1000,-192,-192,-192,-192,-192,-192,-1000,
  463. -1000,-251,-251,-251,-214 };
  464. short yypgo[]={
  465.  
  466.    0, 107,  82,  60,  49,  52 };
  467. short yyr1[]={
  468.  
  469.    0,   3,   3,   3,   5,   5,   5,   5,   5,   5,
  470.    4,   4,   4,   4,   4,   4,   4,   4,   4,   4,
  471.    4,   4,   4,   4,   4,   4,   4,   4,   4,   4,
  472.    2,   2,   2,   2,   2,   2,   1,   1,   1,   1,
  473.    1,   1,   1,   1,   1 };
  474. short yyr2[]={
  475.  
  476.    0,   2,   2,   1,   3,   3,   3,   2,   1,   1,
  477.    3,   3,   3,   3,   3,   3,   3,   3,   3,   3,
  478.    3,   3,   3,   3,   3,   3,   3,   3,   3,   3,
  479.    3,   3,   3,   3,   3,   3,   3,   3,   2,   3,
  480.    2,   3,   3,   3,   1 };
  481. short yychk[]={
  482.  
  483. -1000,  -3,  -5, 256, 259, 265, 270,  -4,  -2, 275,
  484.  261, 277,  -1, 276, 267, 271, 259, 257, 272, 259,
  485.   -5,  -1,  -5, 260, 269, 273, 274, 260, 269, 273,
  486.  274, 260, 269, 273, 274, 266, 263, 269, 260, 262,
  487.  264, 276, 267, 279, 258, 268,  -1, 265,  -1,  -5,
  488.   -5, 278, 278, 275, 261, 277, 275, 261, 277, 275,
  489.  261, 277, 275, 261, 277, 275, 275, 275, 275, 275,
  490.  275, 275, 275,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
  491.   -1,  -1,  -1,  -1,  -1 };
  492. short yydef[]={
  493.  
  494.    0,  -2,   0,   0,   3,   0,   0,   8,   9,   0,
  495.    0,   0,   0,   0,   0,  44,   1,   0,   0,   2,
  496.    0,   0,   7,   0,   0,   0,   0,   0,   0,   0,
  497.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  498.    0,   0,   0,   0,   0,   0,  38,   0,  40,   5,
  499.    6,   4,  36,  10,  14,  18,  11,  15,  19,  12,
  500.   16,  20,  13,  17,  21,  22,  23,  24,  25,  26,
  501.   27,  28,  29,  30,  31,  32,  33,  34,  35,  37,
  502.   39,  41,  42,  43,   0 };
  503. #ifndef lint
  504. static    char yaccpar_sccsid[] = "@(#)yaccpar 1.6 88/02/08 SMI"; /* from UCB 4.1 83/02/11 */
  505. #endif
  506.  
  507. #
  508. # define YYFLAG -1000
  509. # define YYERROR goto yyerrlab
  510. # define YYACCEPT return(0)
  511. # define YYABORT return(1)
  512.  
  513. /*    parser for yacc output    */
  514.  
  515. #ifdef YYDEBUG
  516. int yydebug = 0; /* 1 for debugging */
  517. #endif
  518. YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
  519. int yychar = -1; /* current input token number */
  520. int yynerrs = 0;  /* number of errors */
  521. short yyerrflag = 0;  /* error recovery flag */
  522.  
  523. yyparse() {
  524.  
  525.     short yys[YYMAXDEPTH];
  526.     short yyj, yym;
  527.     register YYSTYPE *yypvt;
  528.     register short yystate, *yyps, yyn;
  529.     register YYSTYPE *yypv;
  530.     register short *yyxi;
  531.  
  532.     yystate = 0;
  533.     yychar = -1;
  534.     yynerrs = 0;
  535.     yyerrflag = 0;
  536.     yyps= &yys[-1];
  537.     yypv= &yyv[-1];
  538.  
  539.  yystack:    /* put a state and value onto the stack */
  540.  
  541. #ifdef YYDEBUG
  542.     if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
  543. #endif
  544.         if( ++yyps>= &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
  545.         *yyps = yystate;
  546.         ++yypv;
  547.         *yypv = yyval;
  548.  
  549.  yynewstate:
  550.  
  551.     yyn = yypact[yystate];
  552.  
  553.     if( yyn<= YYFLAG ) goto yydefault; /* simple state */
  554.  
  555.     if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
  556.     if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
  557.  
  558.     if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
  559.         yychar = -1;
  560.         yyval = yylval;
  561.         yystate = yyn;
  562.         if( yyerrflag > 0 ) --yyerrflag;
  563.         goto yystack;
  564.         }
  565.  
  566.  yydefault:
  567.     /* default state action */
  568.  
  569.     if( (yyn=yydef[yystate]) == -2 ) {
  570.         if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
  571.         /* look through exception table */
  572.  
  573.         for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
  574.  
  575.         while( *(yyxi+=2) >= 0 ){
  576.             if( *yyxi == yychar ) break;
  577.             }
  578.         if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
  579.         }
  580.  
  581.     if( yyn == 0 ){ /* error */
  582.         /* error ... attempt to resume parsing */
  583.  
  584.         switch( yyerrflag ){
  585.  
  586.         case 0:   /* brand new error */
  587.  
  588.             yyerror( "syntax error" );
  589.         yyerrlab:
  590.             ++yynerrs;
  591.  
  592.         case 1:
  593.         case 2: /* incompletely recovered error ... try again */
  594.  
  595.             yyerrflag = 3;
  596.  
  597.             /* find a state where "error" is a legal shift action */
  598.  
  599.             while ( yyps >= yys ) {
  600.                yyn = yypact[*yyps] + YYERRCODE;
  601.                if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
  602.                   yystate = yyact[yyn];  /* simulate a shift of "error" */
  603.                   goto yystack;
  604.                   }
  605.                yyn = yypact[*yyps];
  606.  
  607.                /* the current yyps has no shift onn "error", pop stack */
  608.  
  609. #ifdef YYDEBUG
  610.                if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
  611. #endif
  612.                --yyps;
  613.                --yypv;
  614.                }
  615.  
  616.             /* there is no state on the stack with an error shift ... abort */
  617.  
  618.     yyabort:
  619.             return(1);
  620.  
  621.  
  622.         case 3:  /* no shift yet; clobber input char */
  623.  
  624. #ifdef YYDEBUG
  625.             if( yydebug ) printf( "error recovery discards char %d\n", yychar );
  626. #endif
  627.  
  628.             if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
  629.             yychar = -1;
  630.             goto yynewstate;   /* try again in the same state */
  631.  
  632.             }
  633.  
  634.         }
  635.  
  636.     /* reduction by production yyn */
  637.  
  638. #ifdef YYDEBUG
  639.         if( yydebug ) printf("reduce %d\n",yyn);
  640. #endif
  641.         yyps -= yyr2[yyn];
  642.         yypvt = yypv;
  643.         yypv -= yyr2[yyn];
  644.         yyval = yypv[1];
  645.         yym=yyn;
  646.             /* consult goto table to find next state */
  647.         yyn = yyr1[yyn];
  648.         yyj = yypgo[yyn] + *yyps + 1;
  649.         if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
  650.         switch(yym){
  651.             
  652. case 1:
  653. # line 84 "test.y"
  654. { retval = yypvt[-1].ival ; } break;
  655. case 2:
  656. # line 86 "test.y"
  657. { retval = 1; } break;
  658. case 3:
  659. # line 88 "test.y"
  660. { retval = 0; } break;
  661. case 4:
  662. # line 92 "test.y"
  663. { yyval.ival = yypvt[-1].ival ; } break;
  664. case 5:
  665. # line 94 "test.y"
  666. { yyval.ival = yypvt[-2].ival && yypvt[-0].ival ; } break;
  667. case 6:
  668. # line 96 "test.y"
  669. { yyval.ival = yypvt[-2].ival || yypvt[-0].ival ; } break;
  670. case 7:
  671. # line 98 "test.y"
  672. { yyval.ival = ! yypvt[-0].ival ; } break;
  673. case 8:
  674. # line 100 "test.y"
  675. { yyval.ival = yypvt[-0].ival ; } break;
  676. case 9:
  677. # line 102 "test.y"
  678. { yyval.ival = yypvt[-0].ival ; } break;
  679. case 10:
  680. # line 106 "test.y"
  681. { yyval.ival = (strcmp( yypvt[-2].cval , yypvt[-0].cval ) == 0);
  682.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  683.             } break;
  684. case 11:
  685. # line 110 "test.y"
  686. { yyval.ival = (strcmp( yypvt[-2].cval , yypvt[-0].cval ) != 0);
  687.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  688.             } break;
  689. case 12:
  690. # line 114 "test.y"
  691. { if (smatch( yypvt[-0].cval )) YYERROR; yyval.ival = match( yypvt[-2].cval );
  692.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  693.             } break;
  694. case 13:
  695. # line 118 "test.y"
  696. { if (smatch( yypvt[-0].cval )) YYERROR; yyval.ival = !match( yypvt[-2].cval );
  697.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  698.             } break;
  699. case 14:
  700. # line 122 "test.y"
  701. { yyval.ival = strfp(1, yypvt[-2].cval , yypvt[-0].cval , fopen, fclose);
  702.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  703.             } break;
  704. case 15:
  705. # line 126 "test.y"
  706. { yyval.ival = strfp(0, yypvt[-2].cval , yypvt[-0].cval , fopen, fclose);
  707.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  708.             } break;
  709. case 16:
  710. # line 130 "test.y"
  711. { yyval.ival = patinfp(1, yypvt[-2].cval , yypvt[-0].cval , fopen, fclose);
  712.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  713.             } break;
  714. case 17:
  715. # line 134 "test.y"
  716. { yyval.ival = patinfp(0, yypvt[-2].cval , yypvt[-0].cval , fopen, fclose);
  717.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  718.             } break;
  719. case 18:
  720. # line 138 "test.y"
  721. { yyval.ival = strfp(1, yypvt[-2].cval , yypvt[-0].cval , popen, pclose);
  722.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  723.             } break;
  724. case 19:
  725. # line 142 "test.y"
  726. { yyval.ival = strfp(0, yypvt[-2].cval , yypvt[-0].cval , popen, pclose);
  727.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  728.             } break;
  729. case 20:
  730. # line 146 "test.y"
  731. { yyval.ival = patinfp(1, yypvt[-2].cval , yypvt[-0].cval , popen, pclose);
  732.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  733.             } break;
  734. case 21:
  735. # line 150 "test.y"
  736. { yyval.ival = patinfp(0, yypvt[-2].cval , yypvt[-0].cval , popen, pclose);
  737.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  738.             } break;
  739. case 22:
  740. # line 154 "test.y"
  741. { yyval.ival = strfp(1, yypvt[-0].cval , yypvt[-2].cval , fopen, fclose);
  742.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  743.             } break;
  744. case 23:
  745. # line 158 "test.y"
  746. { yyval.ival = strfp(0, yypvt[-0].cval , yypvt[-2].cval , fopen, fclose);
  747.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  748.             } break;
  749. case 24:
  750. # line 162 "test.y"
  751. { yyval.ival = patfp(1, yypvt[-0].cval , yypvt[-2].cval , fopen, fclose);
  752.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  753.             } break;
  754. case 25:
  755. # line 166 "test.y"
  756. { yyval.ival = patfp(0, yypvt[-0].cval , yypvt[-2].cval , fopen, fclose);
  757.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  758.             } break;
  759. case 26:
  760. # line 170 "test.y"
  761. { yyval.ival = strfp(1, yypvt[-0].cval , yypvt[-2].cval , popen, pclose);
  762.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  763.             } break;
  764. case 27:
  765. # line 174 "test.y"
  766. { yyval.ival = strfp(0, yypvt[-0].cval , yypvt[-2].cval , popen, pclose);
  767.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  768.             } break;
  769. case 28:
  770. # line 178 "test.y"
  771. { yyval.ival = patfp(1, yypvt[-0].cval , yypvt[-2].cval , popen, pclose);
  772.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  773.             } break;
  774. case 29:
  775. # line 182 "test.y"
  776. { yyval.ival = patfp(0, yypvt[-0].cval , yypvt[-2].cval , popen, pclose);
  777.               (void) free( yypvt[-2].cval ); (void) free( yypvt[-0].cval );
  778.             } break;
  779. case 30:
  780. # line 188 "test.y"
  781. { yyval.ival = yypvt[-2].ival < yypvt[-0].ival ; } break;
  782. case 31:
  783. # line 190 "test.y"
  784. { yyval.ival = yypvt[-2].ival > yypvt[-0].ival ; } break;
  785. case 32:
  786. # line 192 "test.y"
  787. { yyval.ival = yypvt[-2].ival != yypvt[-0].ival ; } break;
  788. case 33:
  789. # line 194 "test.y"
  790. { yyval.ival = yypvt[-2].ival == yypvt[-0].ival ; } break;
  791. case 34:
  792. # line 196 "test.y"
  793. { yyval.ival = yypvt[-2].ival >= yypvt[-0].ival ; } break;
  794. case 35:
  795. # line 198 "test.y"
  796. { yyval.ival = yypvt[-2].ival <= yypvt[-0].ival ; } break;
  797. case 36:
  798. # line 202 "test.y"
  799. { yyval.ival = yypvt[-1].ival ; } break;
  800. case 37:
  801. # line 204 "test.y"
  802. { yyval.ival = yypvt[-2].ival + yypvt[-0].ival ; } break;
  803. case 38:
  804. # line 206 "test.y"
  805. { yyval.ival = yypvt[-1].ival ; } break;
  806. case 39:
  807. # line 208 "test.y"
  808. { yyval.ival = yypvt[-2].ival - yypvt[-0].ival ; } break;
  809. case 40:
  810. # line 210 "test.y"
  811. { yyval.ival = - yypvt[-1].ival ; } break;
  812. case 41:
  813. # line 212 "test.y"
  814. { yyval.ival = yypvt[-2].ival * yypvt[-0].ival ; } break;
  815. case 42:
  816. # line 214 "test.y"
  817. { yyval.ival = yypvt[-2].ival / yypvt[-0].ival ; } break;
  818. case 43:
  819. # line 216 "test.y"
  820. { yyval.ival = yypvt[-2].ival % yypvt[-0].ival ; } break;
  821. case 44:
  822. # line 218 "test.y"
  823. { yyval.ival = yypvt[-0].ival ; } break;
  824.         }
  825.         goto yystack;  /* stack new state and value */
  826.  
  827.     }
  828.